home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
quikc21.zip
/
QINITEST.C
< prev
next >
Wrap
Text File
|
1989-07-06
|
15KB
|
398 lines
/*===========================================================================*\
| QINITEST.C ver 2.1, 07-06-89 |
| |
| Tests your system configuration |
| |
| Copyright (c) 1988,1989 by James H. LeMay, All rights reserved. |
| |
| Conversion to C by Jordan Gallagher / Wisdom Research |
\*===========================================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include "qwikc21.h"
/* un-comment the line below to include IBM's submodel ID detection */
/* #define ADD_SUBMODEL */
char newmode, oldmode;
char strng[80];
char ch;
int cursor_delay=1500;
#ifndef __TURBOC__
union REGS mr;
#define textmode(m) { mr.h.ah=0; mr.h.al=m; int86(0x10,&mr,&mr); }
#endif
/******************************| check_zenith |*****************************\
Since Zenith doesn't have snow on any CGAs, turn off snow checking.
\***************************************************************************/
void check_zenith(void)
{
char tmp[10];
movedata( 0xF000u, 0x800Cu, (unsigned)(((char far *)tmp)+1),
(unsigned)((char far *)tmp), 8 );
if(qsnow && (strncmp( tmp, "ZDS CORP", 8 )) == 0) {
qsnow=0;
cardsnow=0;
}
}
/********************************| clearscr |*******************************\
Clears the screen using the yellow on blue attribute.
\***************************************************************************/
void clearscr(void)
{
qfill( 1, 1, crt_rows, crt_cols, YELLOW+BLUE_BG, ' ' );
}
/*********************************| init |***********************************\
Initializes by checking for Zenith and clearing the screen.
\****************************************************************************/
void init(void)
{
qreinit();
check_zenith();
setmultitask();
#ifdef __TURBOC__
if(inmultask) directvideo=0;
#endif
clearscr();
}
/********************************| btoa |************************************\
Converts a long to a string. The target string contains the long in
binary form, i.e. "10100101101101010010010110110101".
The parameter bitcnt specifies the number of bits to be processed.
The return value is a pointer to the target string.
\****************************************************************************/
char *btoa( long val, char bitcnt, char *string )
{
char bit;
for(bit=0; bit < bitcnt; bit++) {
string[bit] = ((val >> bit) & 1) + 48;
}
string[bit]=0;
return(string);
}
/********************************| htoa |************************************\
Converts a long to a string. The target string contains the long in
hexadecimal form, i.e. "21CF89A5".
The parameter hcnt specifies the amount of characters the target
string should contain.
The return value is a pointer to the target string.
\****************************************************************************/
char *htoa( long val, char hcnt, char *string )
{
if(hcnt > 4)
sprintf( string, "0x%*lX", hcnt, val );
else
if(hcnt > 2)
sprintf( string, "0x%0*X", hcnt, (int) val );
else
if(hcnt <= 2)
sprintf( string, "0x%0*hX", hcnt, (unsigned char) val );
return(string);
}
/*********************************| stryn |**********************************\
Places the string "YES" or "NO" in the str parameter based on whether
the specified int is 1 or 0.
\****************************************************************************/
char *stryn( int val, char *str )
{
return(strcpy( str, val ? "YES" : "NO" ));
}
/******************************| display_dev |*******************************\
Sets the global variable "strng" based on the specified display device's
number.
\****************************************************************************/
void display_dev( char dd )
{
switch(dd) {
case 0x00: strcpy( strng, "No display" ); break;
case 0x01: strcpy( strng, "MDA with 5151 monochrome" ); break;
case 0x02: strcpy( strng, "CGA with 5153/4 color" ); break;
case 0x04: strcpy( strng, "EGA with 5153/4 color" ); break;
case 0x05: strcpy( strng, "EGA with 5151 monochrome" ); break;
case 0x06: strcpy( strng, "PGC with 5175 color" ); break;
case 0x07: strcpy( strng, "VGA with analog monochrome" ); break;
case 0x08: strcpy( strng, "VGA with analog color" ); break;
case 0x0B: strcpy( strng, "MCGA with analog monochrome" ); break;
case 0x0C: strcpy( strng, "MCGA with analog color" ); break;
default: strcpy( strng, "Reserved" );
}
}
/*****************************| do_setcursor |*******************************\
Calls setcursor with the cursor parameter, and displays the specified
message along with a hexadecimal version of the cursor word.
\****************************************************************************/
void do_setcursor( char *msg, unsigned cursor )
{
char msg1[80],msg2[80];
strcpy( msg1, msg );
htoa( (long) cursor, 4, msg2 );
setcursor( cursor );
qwriteeos( SAMEATTR, strcat( msg1, msg2 ) );
gotoeos();
#ifdef __TURBOC__
delay( cursor_delay );
#else
suspend( cursor_delay );
#endif
eosln();
}
/*****************************| do_modcursor |*******************************\
Calls modcursor with the cursor parameter, and displays the specified
message along with a hexadecimal version of the cursor's word after
being set by modcursor.
\****************************************************************************/
void do_modcursor( char *msg, int cursor )
{
char msg1[30],msg2[10],msg3[10];
modcursor( cursor );
strcpy( msg1, msg );
htoa( (long) cursor, 4, msg2 );
htoa( (long) getcursor(), 4, msg3 );
strcat( msg1, msg2 );
strcat( msg1, " " );
strcat( msg1, msg3 );
qwriteeos( SAMEATTR, msg1 );
gotoeos();
#ifdef __TURBOC__
delay( cursor_delay );
#else
suspend( cursor_delay );
#endif
eosln();
}
/*******************************| waitkey |**********************************\
Waits for a keypress, eliminating extra key-ahead if an extended key
is pressed, generating an escape sequence.
\****************************************************************************/
void waitkey(void)
{
qwrite( crt_rows, 1, SAMEATTR, "Press any key..." );
gotoeos();
do ch=getch(); while(kbhit());
}
/*********************************| main |***********************************\
The main block.
\****************************************************************************/
void main()
{
char s[80];
qinit();
init();
oldmode=qvideo_mode;
qwrite( 1, 1, SAMEATTR, "Which text mode (0,1,2,3,7) ? " );
gotoeos();
while( strchr( "01237", (ch=getch()) )==NULL );
newmode=ch-'0';
if(newmode != oldmode) {
textmode( newmode );
qreinit();
}
init();
switch( cpuid ) {
case cpu8086: strcpy( strng, "Intel 8086/88" ); break;
case cpu80186: strcpy( strng, "Intel 80186/188" ); break;
case cpu80286: strcpy( strng, "Intel 80286" ); break;
case cpu80386: strcpy( strng, "Intel 80386" ); break;
}
qwrite( 1, 1, SAMEATTR, "CPU ident = " );
qwriteeos( SAMEATTR, strng );
#ifdef ADD_SUBMODEL
get_submodel_id(); /* Check docs before using this function. */
#endif
switch(system_id) {
case 0xFF: strcpy( strng, "IBM PC" ); break;
case 0xFE: strcpy( strng, "IBM PC